package com.sans.start;

import java.text.BreakIterator;
import java.util.Scanner;

/**
 * @author Sans
 */
public class Calculator {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println(">>欢迎来到计算器");
        while (true) {
            System.out.println(">>请输入第一个数:");
            int num1 = scanner.nextInt();
            System.out.println(">> 请选择运算法则，输入对应的编号:");
            System.out.println("1.加法");
            System.out.println("2.减法");
            System.out.println("3.乘法");
            System.out.println("4.除法");
            System.out.println("5.取余");
            int symbol = scanner.nextInt();
            System.out.println(">>请输入第二个数:");
            int num2 = scanner.nextInt();
            Object result = symbol == 1 ? num1 + num2 : symbol == 2 ? num1 - num2 :
                    symbol == 3 ? num1 * num2 : symbol == 4 ? (double)num1 / num2 :
                            symbol == 5 ? num1 % num2 : "输入错误！";
            System.out.println("结果为:" + result);
        }
    }
}
